//
//  AppDelegate.m
//  07-UITabBarController
//
//  Created by 402030900@qq.com on 16/7/22.
//  Copyright © 2016年 402030900@qq.com. All rights reserved.
//

#import "AppDelegate.h"
#import "ViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    _window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
    _window.backgroundColor = [UIColor whiteColor];
    [_window makeKeyAndVisible];
    
    ViewController * vc1 = [[ViewController alloc]init];
    vc1.view.backgroundColor = [UIColor yellowColor];
    ViewController * vc2 = [[ViewController alloc]init];
    vc2.view.backgroundColor = [UIColor redColor];
    ViewController * vc3 = [[ViewController alloc]init];
    vc3.view.backgroundColor = [UIColor blueColor];
    ViewController * vc4 = [[ViewController alloc]init];
    vc4.view.backgroundColor = [UIColor greenColor];
    ViewController * vc5 = [[ViewController alloc]init];
    vc5.view.backgroundColor = [UIColor whiteColor];
    ViewController * vc6 = [[ViewController alloc]init];
    vc6.view.backgroundColor = [UIColor greenColor];
    
    // navi
    UINavigationController * navi1 = [[UINavigationController alloc]initWithRootViewController:vc1];
    UINavigationController * navi2 = [[UINavigationController alloc]initWithRootViewController:vc2];
    UINavigationController * navi3 = [[UINavigationController alloc]initWithRootViewController:vc3];
    UINavigationController * navi4 = [[UINavigationController alloc]initWithRootViewController:vc4];
    UINavigationController * navi5 = [[UINavigationController alloc]initWithRootViewController:vc5];
    UINavigationController * navi6 = [[UINavigationController alloc]initWithRootViewController:vc6];
    navi1.navigationBar.translucent = NO;
    // tabBar(创建方式三种)
    UITabBarController * tabBar = [[UITabBarController alloc]init];
//    [tabBar setViewControllers:@[navi1,vc2,vc3,vc4]];
    tabBar.viewControllers = @[navi1,navi2,navi3,navi4,navi5,navi6];

    _window.rootViewController = tabBar;
    
  
    vc1.title = @"第一页";
    vc2.title = @"第二页";

    // 两种方式 setter 方法 和 .语法
    // 如果数组个数 > 5,会自动生成一张列表方式进行管理
 
    vc1.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:(UITabBarSystemItemBookmarks) tag:1000];
    vc2.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:(UITabBarSystemItemDownloads) tag:2000];
    vc3.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"news" image:[UIImage imageNamed:@"news"] tag:100];
    vc4.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"movie" image:[UIImage imageNamed:@"movie"] selectedImage:[UIImage imageNamed:@"news"]];
    
    // 1. barTintColor   bar背景色
    tabBar.tabBar.barTintColor = [UIColor colorWithRed:0.912 green:0.482 blue:1.000 alpha:1.000];
    // 2. tintColor    bar元素颜色
    tabBar.tabBar.tintColor = [UIColor blackColor];
    // 3. 高度49
    // 4.translucent 是否透明
    tabBar.tabBar.translucent = YES;
    // 5.tabBarItem.badgeValue 角标
    vc1.tabBarItem.badgeValue = @"1000";
    // 6.UITabBar appearance 全局设置
    [[UINavigationBar appearance]setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithWhite:0.038 alpha:1.000]}];
    [[UITabBar appearance] setTintColor:[UIColor colorWithRed:0.869 green:1.000 blue:0.541 alpha:1.000]];
    [[UITabBar appearance]setBarTintColor:[UIColor lightGrayColor    ]];
    [[UINavigationBar appearance]setTintColor:[UIColor colorWithRed:0.228 green:0.391 blue:1.000 alpha:1.000]];
    // 7.navigationItem.title 和 title (title 只对自定义tabBar 有限制)
    vc1.navigationItem.title = @"aaa";
    vc4.title = @"bbb";

  

    
  
    



    // Override point for customization after application launch.
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
